<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		
		<meta charset="utf-8" />
		<title>菜单</title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link href="<%=contextPath%>/static/css/bootstrap.min.css" rel="stylesheet" />
		<link href="<%=contextPath%>/static/css/bootstrap-responsive.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="<%=contextPath%>/static/css/font-awesome.min.css" />
		<link rel="stylesheet" href="<%=contextPath%>/static/css/ace.min.css" />
		<link rel="stylesheet" href="<%=contextPath%>/static/css/ace-responsive.min.css" />
		<link rel="stylesheet" href="<%=contextPath%>/static/css/ace-skins.min.css" />
		<script type="text/javascript" src="<%=contextPath%>/static/js/jquery-1.7.2.js"></script>
		<!-- ajax表单提交-->
		<script src="<%=contextPath%>/js/jquery.form.js"></script>
		<!--提示框-->
		<script type="text/javascript" src="<%=contextPath%>/static/js/jquery.tips.js"></script>
</head>

<script type="text/javascript">
	$(top.hangge());
	//保存
	function save(){
		if($("#menuName").val()==""){
			
			$("#menuName").tips({
				side:3,
	            msg:'请输入菜单名称',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#menuName").focus();
			return false;
		}
		if($("#menuUrl").val()==""){
			$("#menuUrl").val('#');
		}
		if($("#menuOrder").val()==""){
			
			$("#menuOrder").tips({
				side:1,
	            msg:'请输入菜单序号',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#menuOrder").focus();
			return false;
		}
		
		if(isNaN(Number($("#menuOrder").val()))){
			
			$("#menuOrder").tips({
				side:1,
	            msg:'请输入菜单序号',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#menuOrder").focus();
			$("#menuOrder").val(1);
			return false;
		}
		$("#zhongxin").hide();
		$("#zhongxin2").show();
		$("#menuForm").ajaxSubmit({
        	url:'<%=contextPath%>/menu/add',
        	type:'post',
        	dataType:"json",
        	success:function(data){
        		if(data.code==200){
        			top.Dialog.close();
        		}else{
        			alert("错误");
        			$("#zhongxin").show();
        			$("#zhongxin2").hide();
        		}
        	}
      }); 
		
	}
</script>


<body>
	<form  action="menu/add" name="menuForm" id="menuForm" method="post" >
		<input type="hidden" name="state" id="" value="1"/>
		<input type="hidden" name="display" id="MENU_TYPE" value="2"/>
		<input type="hidden" name="type" id="type" value="2"/>
		<div id="zhongxin">
		<table>
			<tr>
				<td>
					<select name="parentId" id="parentId" class="input_txt"   title="菜单">
							<option value="${resource.id }" onclick="">${resource.name }</option>
					</select>
				</td>
			</tr>
			<tr>
				<td><input type="text" name="name" id="menuName" placeholder="这里输入名称" value="" title="名称"/></td>
			</tr>
			<tr>
				<td><input type="text" name="href" id="menuUrl" placeholder="这里输入链接地址" value="" title="地址"/></td>
			</tr>
			<tr>
				<td><input type="text" name="permission" id="permission" placeholder="这里输入权限" value="" title="权限"/></td>
			</tr>
			<tr>
				<td><input type="number" name="sort" id="menuOrder" placeholder="这里输入序号" value="" title="序号"/></td>
			</tr>
			<tr>
				<td style="text-align: center;">
					<label style="float:left;padding-left: 32px;"><input name="form-field-radio" id="form-field-radio1" onclick="setType('1');" type="radio" value="icon-edit"><span class="lbl">系统菜单</span></label>
					<label style="float:left;padding-left: 5px;"><input name="form-field-radio" id="form-field-radio2" onclick="setType('2');" type="radio" value="icon-edit"><span class="lbl">业务菜单</span></label>
				</td>
			</tr>
			<tr>
				<td style="text-align: center; padding-top: 10px;">
					<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
					<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
				</td>
			</tr>
		</table>
		</div>
		<div id="zhongxin2" class="center" style="display:block;"><br/><br/><br/><img src="<%=contextPath%>/static/images/jiazai.gif" /><br/><h4 class="lighter block green"></h4></div>
	</form>
</body>
</html>